package GUINew;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import java.awt.Color;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import javax.swing.JSeparator;
import java.awt.GridLayout;
import javax.swing.JButton;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.FlowLayout;
import javax.swing.border.LineBorder;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JToggleButton;
import java.awt.Dimension;
import java.awt.Toolkit;

public class MainWindowFrame
{

   private JFrame frmRovControl;
   private JPanel navigationPanel;
   private JPanel videoStreamPanel;
   private JPanel statusPanel;
   private JMenuItem controlMenuItem;


   /**
    * Create the application.
    */
   public MainWindowFrame()
   {
      initialize();
   }

   /**
    * Initialize the contents of the frame.
    */
   void initialize()
   {
      frmRovControl = new JFrame();
      frmRovControl.setIconImage(Toolkit.getDefaultToolkit().getImage(MainWindowFrame.class.getResource("/icons/yellow_submarine.png")));
      frmRovControl.getContentPane().setBackground(Color.DARK_GRAY);
      frmRovControl.setTitle("ROV - Control");
      frmRovControl.setResizable(false);
      frmRovControl.setBounds(100, 100, 1110, 620);
      frmRovControl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      
      JMenuBar menuBar = new JMenuBar();
      frmRovControl.setJMenuBar(menuBar);
      
      JMenu connectionMenu = new JMenu("Connection");
      menuBar.add(connectionMenu);
      
      JMenuItem connectionMenuItem = new JMenuItem("Verbinden");
      connectionMenu.add(connectionMenuItem);
      
      JSeparator separator = new JSeparator();
      connectionMenu.add(separator);
      
      JMenuItem closeMenuItem = new JMenuItem("Beenden");
      connectionMenu.add(closeMenuItem);
      
      JMenu settingsMenu = new JMenu("Einstellungen");
      menuBar.add(settingsMenu);
      
      controlMenuItem = new JMenuItem("Steuerung");
      settingsMenu.add(controlMenuItem);
      
      JMenuItem mntmWirc = new JMenuItem("WiRC");
      settingsMenu.add(mntmWirc);
      frmRovControl.getContentPane().setLayout(new BorderLayout(0, 0));
      
      statusPanel = new JPanel();
      statusPanel.setBackground(Color.DARK_GRAY);
      statusPanel.setPreferredSize(new Dimension(240, 480));
      frmRovControl.getContentPane().add(statusPanel, BorderLayout.WEST);
      
      navigationPanel = new JPanel();
      navigationPanel.setBackground(Color.DARK_GRAY);
      navigationPanel.setPreferredSize(new Dimension(240, 480));
      frmRovControl.getContentPane().add(navigationPanel, BorderLayout.EAST);
      navigationPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
      
      JPanel videoPanel = new JPanel();
      videoPanel.setBackground(Color.DARK_GRAY);
      frmRovControl.getContentPane().add(videoPanel, BorderLayout.CENTER);
      GridBagLayout gbl_videoPanel = new GridBagLayout();
      gbl_videoPanel.columnWidths = new int[]{0, 0};
      gbl_videoPanel.rowHeights = new int[]{0, 0, 0};
      gbl_videoPanel.columnWeights = new double[]{1.0, Double.MIN_VALUE};
      gbl_videoPanel.rowWeights = new double[]{1.0, 0.0, Double.MIN_VALUE};
      videoPanel.setLayout(gbl_videoPanel);
      
      videoStreamPanel = new JPanel();
      videoStreamPanel.setBackground(Color.DARK_GRAY);
      videoStreamPanel.setMaximumSize(new Dimension(650, 490));
      videoStreamPanel.setPreferredSize(new Dimension(650, 490));
      videoStreamPanel.setBorder(null);
      GridBagConstraints gbc_videoStreamPanel = new GridBagConstraints();
      gbc_videoStreamPanel.insets = new Insets(0, 0, 5, 0);
      gbc_videoStreamPanel.fill = GridBagConstraints.BOTH;
      gbc_videoStreamPanel.gridx = 0;
      gbc_videoStreamPanel.gridy = 0;
      videoPanel.add(videoStreamPanel, gbc_videoStreamPanel);
      GridBagLayout gbl_videoStreamPanel = new GridBagLayout();
      gbl_videoStreamPanel.columnWidths = new int[]{0};
      gbl_videoStreamPanel.rowHeights = new int[]{0};
      gbl_videoStreamPanel.columnWeights = new double[]{Double.MIN_VALUE};
      gbl_videoStreamPanel.rowWeights = new double[]{Double.MIN_VALUE};
      videoStreamPanel.setLayout(gbl_videoStreamPanel);
      
      JPanel videoControlPanel = new JPanel();
      videoControlPanel.setBackground(Color.DARK_GRAY);
      GridBagConstraints gbc_videoControlPanel = new GridBagConstraints();
      gbc_videoControlPanel.fill = GridBagConstraints.BOTH;
      gbc_videoControlPanel.gridx = 0;
      gbc_videoControlPanel.gridy = 1;
      videoPanel.add(videoControlPanel, gbc_videoControlPanel);
      videoControlPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
      
      JToggleButton videoRecBtn = new JToggleButton("");
      videoRecBtn.setIcon(new ImageIcon(MainWindowFrame.class.getResource("/icons/rec_record.png")));
      videoControlPanel.add(videoRecBtn);
      
      JToggleButton videoPlayBtn = new JToggleButton("");
      videoPlayBtn.setSelectedIcon(new ImageIcon(MainWindowFrame.class.getResource("/icons/player_pause.png")));
      videoPlayBtn.setIcon(new ImageIcon(MainWindowFrame.class.getResource("/icons/player_play.png")));
      videoControlPanel.add(videoPlayBtn);
      
      JButton videoStopBtn = new JButton("");
      videoStopBtn.setIcon(new ImageIcon(MainWindowFrame.class.getResource("/icons/player_stop.png")));
      videoControlPanel.add(videoStopBtn);
      frmRovControl.setVisible(true);
   }
   
   public JPanel getNavigationPanel() {
      return navigationPanel;
   }
   public JPanel getVideoStreamPanel() {
      return videoStreamPanel;
   }
   public JPanel getStatusPanel() {
      return statusPanel;
   }
   public JMenuItem getControlMenuItem() {
      return controlMenuItem;
   }
   public JFrame getFrmRovControl() {
      return frmRovControl;
   }
}
